<template>
  <div class="newsinfo-container">
    <h1 class="title">{{newsinfo.title}}</h1>
    <p class="subTitle">
      <span>发表时间：{{newsinfo.add_time | dateFormat}}</span>
      <span>点击：{{newsinfo.click}}次</span>
    </p>
    <hr>
    <div class="content" v-html="newsinfo.content"></div>
    <!-- 父组件向子组件传递id -->
    <content-box :id="id"></content-box>
  </div>
</template>
<script>
//导入评价子组件
import content from "../subcomponents/content.vue"
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsinfo: {}//新闻资讯详情
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      this.$http
        .get("api/getnew/" + this.id)
        .then(result => {
          if (result.body.status == 0) {
            this.newsinfo = result.body.message[0];
            // console.log(this.newsinfo);
          }
        });
    }
  },
  components:{
    "content-box":content
  }
};
</script>
<style lang="scss">
.newsinfo-container{
    padding: 0 5px;
    .title{
        font-size: 16px;
        margin: 10px 0;
        text-align: center;
        color:red;
    }
    .subTitle{
        color: #226aff;
        display: flex;
        justify-content: space-between;
    }
}
</style>
